import React from 'react'
import ReactDOM from 'react-dom'

// ----- redux -----
import {createStore, applyMiddleware} from 'redux'
import {Provider} from 'react-redux'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'
// ----- redux -----

import reducers from './reducers'
import App from './App'

// 通过服务端注入的全局变量得到初始 state
const preloadedState = window.__INITIAL_STATE__ || {user: {name: 'SkyFucker', age: 26}}
console.log(preloadedState);

const logger = createLogger();
const store = createStore(reducers, preloadedState, applyMiddleware(thunkMiddleware, logger));

ReactDOM.render(<Provider store={store}>
    <App />
</Provider>, document.getElementById('app'));







